#pragma once
#include <QWidget>
#include <QMenu>
#include <QPushButton>
#include <QMetaType>

typedef enum class clicktype
{
	CLICK_HELP = 1,   //帮助中心
	CLICK_NOTICE,     //消息中心
	CLICK_ACCOUNTINFO, //账户信息
	
	//设置按钮的菜单
	CLICK_QUICKRES,
	CLICK_EXCELADDIN,
	CLICK_ABOUT,
	CLICK_SYSSETTING,
	CLICK_LOGOUT,
	CLICK_MOBILECONFIRM,
	CLICK_QM
} ClickType;
typedef void(*ClickStatusBar)(ClickType);

class QLabel;
class QPushButton;
class DisconnectShow : public QWidget {
	Q_OBJECT
public:
	explicit DisconnectShow(QWidget* parent = nullptr);
	~DisconnectShow();
	void SetConnectingStatus(bool connecting);

protected:
	void paintEvent(QPaintEvent* event) override;

protected slots:
	void OnTryAgainClicked();

private:
	void InitUI(void);

private:
	QLabel* m_networkStatus;
	QLabel* m_customer;
	QPushButton* m_tryButton;
	int m_netStatus;
	bool m_connecting;
};

class MainFrame;
class SImageButton;
class StatusBar : public QWidget {
	Q_OBJECT
public:
	StatusBar(MainFrame* frame, QWidget* parent = nullptr);
	~StatusBar();
	void setNetworkState(int state);
	void setMsgCenterNotify(int count);
	void onWindowMoved();

protected:
	virtual void paintEvent(QPaintEvent* event) override;
	virtual void resizeEvent(QResizeEvent* event) override;
	virtual void moveEvent(QMoveEvent* event) override;
	virtual void mouseMoveEvent(QMouseEvent* event) override;
	virtual void mousePressEvent(QMouseEvent* event) override;

protected slots:
	void onHelpClicked();
	void onNoticeClicked();
	void onAccoutinfoClicked();
	void onSettingClicked();

	//setting按钮消息响应	
	void onMenuAboutQB();
	void onMenuMobileQB();
	void onMenuExcelPlugin();
	void onMenuSysSetting();
	void onMenuMobileConfirm();
	void onMenuLogout();

private:
	void initialize();
	void updateNetStatus();
	void showDlgDisconnected();
	void hideDlgDisconnected();
	QString getSystemTime();

private:
	MainFrame* m_frame;
	QTimer* m_tmSysTime;
	QTimer* m_tmNetState;
	QTimer* m_tmAutoHideDlgDisconnect;
	DisconnectShow* m_dlgDisconnectShow;
	SImageButton* m_btnNetState;
	SImageButton* m_btnMsgCenter;

	int m_msgCount;
	int m_networkState;
	bool m_netOK;
};
